BEGIN;
CREATE TABLE `account` (
    `id` integer NOT NULL PRIMARY KEY,
    `activation_key` varchar(192) NOT NULL,
    `email` varchar(75) NOT NULL,
    `password` varchar(192) NOT NULL,
    `date_created` datetime NOT NULL,
    `date_activated` datetime NULL,
    `type` varchar(1) NOT NULL,
    `hash` varchar(135) NOT NULL,
    `profile_id` integer NULL,
    `message_id` integer NULL,
    `preference_id` integer NULL,
    `status` varchar(3) NOT NULL,
    `gender` varchar(1) NOT NULL
)
;
CREATE TABLE `article` (
    `id` integer NOT NULL PRIMARY KEY,
    `title` varchar(750) NOT NULL,
    `slug` varchar(750) NOT NULL,
    `excerpt` varchar(150) NOT NULL,
    `body` longtext NOT NULL,
    `date_created` datetime NOT NULL,
    `date_update` datetime NOT NULL,
    `published` bool NOT NULL,
    `date_published` datetime NOT NULL
)
;
CREATE TABLE `auth_group` (
    `id` integer NOT NULL PRIMARY KEY,
    `name` varchar(240) NOT NULL UNIQUE
)
;
CREATE TABLE `auth_group_permissions` (
    `id` integer NOT NULL PRIMARY KEY,
    `group_id` integer NOT NULL UNIQUE,
    `permission_id` integer NOT NULL
)
;
CREATE TABLE `auth_message` (
    `id` integer NOT NULL PRIMARY KEY,
    `user_id` integer NOT NULL,
    `message` longtext NOT NULL
)
;
CREATE TABLE `auth_permission` (
    `id` integer NOT NULL PRIMARY KEY,
    `name` varchar(150) NOT NULL,
    `content_type_id` integer NOT NULL,
    `codename` varchar(300) NOT NULL UNIQUE
)
;
CREATE TABLE `auth_user` (
    `id` integer NOT NULL PRIMARY KEY,
    `username` varchar(90) NOT NULL UNIQUE,
    `first_name` varchar(90) NOT NULL,
    `last_name` varchar(90) NOT NULL,
    `email` varchar(225) NOT NULL,
    `password` varchar(384) NOT NULL,
    `is_staff` integer NOT NULL,
    `is_active` integer NOT NULL,
    `is_superuser` integer NOT NULL,
    `last_login` datetime NOT NULL,
    `date_joined` datetime NOT NULL
)
;
CREATE TABLE `auth_user_groups` (
    `id` integer NOT NULL PRIMARY KEY,
    `user_id` integer NOT NULL UNIQUE,
    `group_id` integer NOT NULL
)
;
CREATE TABLE `auth_user_user_permissions` (
    `id` integer NOT NULL PRIMARY KEY,
    `user_id` integer NOT NULL UNIQUE,
    `permission_id` integer NOT NULL
)
;
CREATE TABLE `countries` (
    `id` integer NOT NULL PRIMARY KEY,
    `code` varchar(15) NOT NULL,
    `name` varchar(765) NOT NULL
)
;
CREATE TABLE `django_admin_log` (
    `id` integer NOT NULL PRIMARY KEY,
    `action_time` datetime NOT NULL,
    `user_id` integer NOT NULL,
    `content_type_id` integer NULL,
    `object_id` longtext NOT NULL,
    `object_repr` varchar(600) NOT NULL,
    `action_flag` integer NOT NULL,
    `change_message` longtext NOT NULL
)
;
CREATE TABLE `django_content_type` (
    `id` integer NOT NULL PRIMARY KEY,
    `name` varchar(300) NOT NULL,
    `app_label` varchar(300) NOT NULL UNIQUE,
    `model` varchar(300) NOT NULL UNIQUE
)
;
CREATE TABLE `django_session` (
    `session_key` varchar(120) NOT NULL PRIMARY KEY,
    `session_data` longtext NOT NULL,
    `expire_date` datetime NOT NULL
)
;
CREATE TABLE `django_site` (
    `id` integer NOT NULL PRIMARY KEY,
    `domain` varchar(300) NOT NULL,
    `name` varchar(150) NOT NULL
)
;
CREATE TABLE `group` (
    `id` integer NOT NULL PRIMARY KEY,
    `name` varchar(135) NOT NULL,
    `description` longtext NOT NULL,
    `date_created` datetime NOT NULL
)
;
CREATE TABLE `job` (
    `id` integer NOT NULL PRIMARY KEY,
    `title` varchar(750) NOT NULL,
    `description` longtext NOT NULL,
    `date_created` datetime NOT NULL,
    `expire_date` datetime NULL
)
;
CREATE TABLE `interest` (
    `id` integer NOT NULL PRIMARY KEY,
    `tag` varchar(50) NOT NULL,
    `normalized` varchar(70) NOT NULL
)
;
CREATE TABLE `jobspeople` (
    `id` integer NOT NULL PRIMARY KEY,
    `date_joined` datetime NOT NULL
)
;
CREATE TABLE `message` (
    `id` integer NOT NULL PRIMARY KEY,
    `subject` varchar(600) NOT NULL,
    `body` longtext NOT NULL,
    `date_sent` datetime NOT NULL,
    `date_read` datetime NULL
)
;
CREATE TABLE `page` (
    `id` integer NOT NULL PRIMARY KEY,
    `title` varchar(750) NOT NULL,
    `slug` varchar(750) NOT NULL,
    `body` longtext NOT NULL,
    `date_created` datetime NOT NULL
)
;
CREATE TABLE `preferences` (
    `id` integer NOT NULL PRIMARY KEY,
    `show_name` bool NOT NULL,
    `show_birthdate` bool NOT NULL,
    `show_mobile` bool NOT NULL,
    `show_city` bool NOT NULL,
    `show_area` bool NOT NULL,
    `receive_sms` bool NOT NULL,
    `receive_email` bool NOT NULL
)
;
CREATE TABLE `profile` (
    `id` integer NOT NULL PRIMARY KEY,
    `first_name` varchar(135) NOT NULL,
    `middle_name` varchar(135) NOT NULL,
    `family_name` varchar(135) NOT NULL,
    `birth_date` date NULL,
    `land` varchar(60) NOT NULL,
    `mobile` varchar(60) NOT NULL,
    `area` varchar(135) NOT NULL,
    `city` varchar(135) NOT NULL,
    `last_updated` datetime NOT NULL
)
;
CREATE TABLE `registration_registrationprofile` (
    `id` integer NOT NULL PRIMARY KEY,
    `user_id` integer NOT NULL UNIQUE,
    `activation_key` varchar(120) NOT NULL
)
;
CREATE TABLE `sms` (
    `id` integer NOT NULL PRIMARY KEY,
    `message` varchar(720) NOT NULL,
    `date_sent` datetime NOT NULL
)
;
CREATE TABLE `group_account_id` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `group_id` integer NOT NULL,
    `account_id` integer NOT NULL,
    UNIQUE (`group_id`, `account_id`)
)
;
ALTER TABLE `group_account_id` ADD CONSTRAINT group_id_refs_id_460475bc FOREIGN KEY (`group_id`) REFERENCES `group` (`id`);
ALTER TABLE `group_account_id` ADD CONSTRAINT account_id_refs_id_7218eab6 FOREIGN KEY (`account_id`) REFERENCES `account` (`id`);
CREATE TABLE `job_account_id` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `job_id` integer NOT NULL,
    `account_id` integer NOT NULL,
    UNIQUE (`job_id`, `account_id`)
)
;
ALTER TABLE `job_account_id` ADD CONSTRAINT job_id_refs_id_7b77d594 FOREIGN KEY (`job_id`) REFERENCES `job` (`id`);
ALTER TABLE `job_account_id` ADD CONSTRAINT account_id_refs_id_164736e4 FOREIGN KEY (`account_id`) REFERENCES `account` (`id`);
CREATE TABLE `interest_account_id` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `interest_id` integer NOT NULL,
    `account_id` integer NOT NULL,
    UNIQUE (`interest_id`, `account_id`)
)
;
ALTER TABLE `interest_account_id` ADD CONSTRAINT interest_id_refs_id_5c7a10d8 FOREIGN KEY (`interest_id`) REFERENCES `interest` (`id`);
ALTER TABLE `interest_account_id` ADD CONSTRAINT account_id_refs_id_38d25e24 FOREIGN KEY (`account_id`) REFERENCES `account` (`id`);
CREATE TABLE `interest_job_id` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `interest_id` integer NOT NULL,
    `job_id` integer NOT NULL,
    UNIQUE (`interest_id`, `job_id`)
)
;
ALTER TABLE `interest_job_id` ADD CONSTRAINT interest_id_refs_id_6b3e2a60 FOREIGN KEY (`interest_id`) REFERENCES `interest` (`id`);
ALTER TABLE `interest_job_id` ADD CONSTRAINT job_id_refs_id_61cf7cc FOREIGN KEY (`job_id`) REFERENCES `job` (`id`);
CREATE TABLE `jobspeople_job_id` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `jobspeople_id` integer NOT NULL,
    `job_id` integer NOT NULL,
    UNIQUE (`jobspeople_id`, `job_id`)
)
;
ALTER TABLE `jobspeople_job_id` ADD CONSTRAINT jobspeople_id_refs_id_7b8338d8 FOREIGN KEY (`jobspeople_id`) REFERENCES `jobspeople` (`id`);
ALTER TABLE `jobspeople_job_id` ADD CONSTRAINT job_id_refs_id_73c7b8dd FOREIGN KEY (`job_id`) REFERENCES `job` (`id`);
CREATE TABLE `jobspeople_account_id` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `jobspeople_id` integer NOT NULL,
    `account_id` integer NOT NULL,
    UNIQUE (`jobspeople_id`, `account_id`)
)
;
ALTER TABLE `jobspeople_account_id` ADD CONSTRAINT jobspeople_id_refs_id_7917ae60 FOREIGN KEY (`jobspeople_id`) REFERENCES `jobspeople` (`id`);
ALTER TABLE `jobspeople_account_id` ADD CONSTRAINT account_id_refs_id_cf6cfc5 FOREIGN KEY (`account_id`) REFERENCES `account` (`id`);
CREATE TABLE `message_account_id` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `message_id` integer NOT NULL,
    `account_id` integer NOT NULL,
    UNIQUE (`message_id`, `account_id`)
)
;
ALTER TABLE `message_account_id` ADD CONSTRAINT message_id_refs_id_4f8543cc FOREIGN KEY (`message_id`) REFERENCES `message` (`id`);
ALTER TABLE `message_account_id` ADD CONSTRAINT account_id_refs_id_7a28377c FOREIGN KEY (`account_id`) REFERENCES `account` (`id`);
CREATE TABLE `profile_country` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `profile_id` integer NOT NULL,
    `countries_id` integer NOT NULL,
    UNIQUE (`profile_id`, `countries_id`)
)
;
ALTER TABLE `profile_country` ADD CONSTRAINT profile_id_refs_id_732f1ce0 FOREIGN KEY (`profile_id`) REFERENCES `profile` (`id`);
ALTER TABLE `profile_country` ADD CONSTRAINT countries_id_refs_id_4ccee0d1 FOREIGN KEY (`countries_id`) REFERENCES `countries` (`id`);
CREATE TABLE `profile_account_id` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `profile_id` integer NOT NULL,
    `account_id` integer NOT NULL,
    UNIQUE (`profile_id`, `account_id`)
)
;
ALTER TABLE `profile_account_id` ADD CONSTRAINT profile_id_refs_id_6550efc4 FOREIGN KEY (`profile_id`) REFERENCES `profile` (`id`);
ALTER TABLE `profile_account_id` ADD CONSTRAINT account_id_refs_id_11363756 FOREIGN KEY (`account_id`) REFERENCES `account` (`id`);
CREATE TABLE `sms_account_id` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `sms_id` integer NOT NULL,
    `account_id` integer NOT NULL,
    UNIQUE (`sms_id`, `account_id`)
)
;
ALTER TABLE `sms_account_id` ADD CONSTRAINT sms_id_refs_id_3c4c16ac FOREIGN KEY (`sms_id`) REFERENCES `sms` (`id`);
ALTER TABLE `sms_account_id` ADD CONSTRAINT account_id_refs_id_70f7a6e6 FOREIGN KEY (`account_id`) REFERENCES `account` (`id`);
CREATE INDEX `account_status` ON `account` (`status`);
CREATE INDEX `article_slug` ON `article` (`slug`);
COMMIT;
